package com.lhsy.djcloud.controller;

import cn.hutool.crypto.SecureUtil;
import com.lhsy.djcloud.common.SignUtil;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class SignController {
    private final static String appId = "c0f23a46f0c84fa2a864a787448729e3";
    private final static String appKey = "WjNrAfH4tiRE9fQ2Jbxz";
    @RequestMapping(value = "/sign",method = RequestMethod.POST)
    public String sign(@RequestBody String serial) throws JSONException {
        log.info("参数[{}]",serial);
        String s = SignUtil.jsonObjConverSortStr(serial);
        String sign = SecureUtil.md5(s + SecureUtil.md5(appId + appKey));
        return sign;
    }
}
